import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:pornhub_app/components/app_bg_view.dart';
import 'package:pornhub_app/components/image_view.dart';
import 'package:pornhub_app/components/text_view.dart';
import 'package:pornhub_app/generate/app_image_path.dart';
import 'package:pornhub_app/utils/extension.dart';
import 'package:pornhub_app/utils/utils.dart';
import '../../../assets/styles.dart';
import '../../../utils/color.dart';
import '../frontpage/controller/edit_userinfo_controller.dart';
import 'edit_user_head_page.dart';

///编辑资料
class EditUserInfoPage extends GetView<EditUserInfoController> {
    const EditUserInfoPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Styles.color.bgColor,
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        iconTheme: const IconThemeData(color: Colors.white),
        title: Text("设置",
            textAlign: TextAlign.center,
            style: TextStyle(
              color: COLOR.hexColor('#ffffff'),
              fontSize: 16.sp,
              fontWeight: FontWeight.w500,
            )),
        centerTitle: true,

      ),
      body: _buildContent(),
    );
  }

  _buildContent() {
    return Column(
      children: [
        Expanded(
          child: Stack(
            children: [
              SingleChildScrollView(
                child: Container(
                  padding: EdgeInsets.symmetric(vertical: 30.w),
                  width: double.infinity,
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      const EditUserHeadPage(),
                      SizedBox(height: 20.w),
                      Flex(
                        direction: Axis.horizontal,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          Expanded(
                            child: Flex(
                              direction: Axis.horizontal,
                              children: [
                                SizedBox(width: 15.w),
                                SizedBox(
                                  width: 50.w,
                                  child: Text(
                                    "昵称",
                                    style: TextStyle(
                                      fontSize: 16.sp,
                                      color: COLOR.hexColor('#ffffff'),
                                    ),
                                  ),
                                ),
                                Expanded(
                                  child: Container(
                                    height: 50.w,
                                    alignment: Alignment.centerLeft,
                                    decoration: BoxDecoration(border: Border(
                                        bottom: BorderSide(color: COLOR.hexColor("#38ffffff")))),
                                    child: TextField(
                                      controller: controller.nickNameController,
                                      // expands: true,
                                      decoration: InputDecoration(
                                        hintText: '请输入昵称',
                                        border: InputBorder.none,
                                        hintStyle: TextStyle(
                                          color: Colors.white,
                                          fontSize: 14.sp,
                                          fontWeight: FontWeight.w600
                                        ),
                                      ),
                                      style: TextStyle(
                                        color: Colors.white,
                                        fontSize: 14.sp,
                                        fontWeight: FontWeight.w600
                                      ),
                                      onSubmitted: (value) {
                                        // 处理搜索逻辑
                                        // _handleSearch();
                                      },
                                    ),
                                  ),
                                ),
                                SizedBox(width: 15.w,)
                              ],
                            ),
                          ),
                        ],
                      ),
                      InkWell(
                        highlightColor: Styles.color.bgColor,
                        splashColor: Styles.color.bgColor,
                        onTap: () => controller.onClick("手机"),
                        child: Row(
                          // direction: Axis.horizontal,
                          mainAxisAlignment: MainAxisAlignment.start,
                          children: [
                            Expanded(
                              child: Flex(
                                direction: Axis.horizontal,
                                children: [
                                  SizedBox(width: 15.w),
                                  SizedBox(
                                    width: 50.w,
                                    child: Text(
                                      "手机",
                                      style: TextStyle(
                                        fontSize: 14.sp,
                                        color: COLOR.hexColor('#ffffff'),
                                      ),
                                    ),
                                  ),
                                  Expanded(
                                    child: Container(
                                      height: 50.w,
                                      alignment: Alignment.centerLeft,
                                      decoration: BoxDecoration(border: Border(
                                          bottom: BorderSide(color: COLOR.hexColor("#38ffffff")))),
                                      child: Row(
                                        children: [
                                          Expanded(
                                            child: SizedBox(
                                              // width: 60.w,
                                              child: Text(
                                                controller.userInfo.mobile.isEmpty ? "请输入手机号码" : controller.userInfo.mobile,
                                                style: TextStyle(
                                                  fontSize: 14.sp,
                                                  color: COLOR.hexColor('#ffffff'),
                                                  fontWeight: FontWeight.w600
                                                ),
                                              ),
                                            ),
                                          ),
                                          
                                          ImageView(
                                            src: AppImagePath.icons_ic_arrow_right,
                                            height: 12.w,
                                            fit: BoxFit.fitHeight,
                                          ),
                                          SizedBox(width: 5.w),
                                        ],
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            SizedBox(width: 10.w),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
              ),
              Positioned(
                left: 20.w,
                right: 20.w,
                bottom: 49.w,
                child: GestureDetector(
                  onTap: () {
                    controller.onClick("保存");
                  },
                  child: Container(
                    alignment: Alignment.center,
                    height: 44.w,
                    decoration: BoxDecoration(
                      color: COLOR.color_FF9205,
                      borderRadius: BorderRadius.circular(22.w),
                    ),
                    child: Text(
                      "保存",
                      style: TextStyle(
                          color: COLOR.black,
                          fontSize: 16.w,
                          fontWeight: FontWeight.w500),
                    ),
                  ),
                ),)
            ],
          ),
        ),
      ],
    );
  }

  Widget _buldChildContent(String title, String content, String colorTxt) {
    return Flex(
      direction: Axis.horizontal,
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Expanded(
          child: Flex(
            direction: Axis.horizontal,
            children: [
              SizedBox(width: 20.w),
              SizedBox(
                width: 60.w,
                child: Text(
                  title,
                  style: TextStyle(
                    fontSize: 14.sp,
                    color: COLOR.hexColor('#ffffff'),
                  ),
                ),
              ),
              Expanded(
                child: Container(
                  height: 50.w,
                  alignment: Alignment.centerLeft,
                  decoration: BoxDecoration(border: Border(
                      bottom: BorderSide(color: COLOR.hexColor("#38ffffff")))),
                  child: TextField(
                    controller: controller.nickNameController,
                    // expands: true,
                    decoration: InputDecoration(
                      hintText: '搜索喜欢的游戏',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        color: Colors.white70,
                        fontSize: 15.sp,
                      ),
                    ),
                    style: TextStyle(
                      color: Colors.white70,
                      fontSize: 15.sp,
                    ),
                    onSubmitted: (value) {
                      // 处理搜索逻辑
                      // _handleSearch();
                    },
                  ),
                ),
              ),
            ],
          ),
        ),
        SizedBox(width: 10.w),
        // Image.asset(
        //   "assets/mine/img_hide_apps_more.png",
        //   width: 7.w,
        //   height: 12.w,
        // ),
        ImageView(
          src: AppImagePath.icons_ic_arrow_right,
          height: 12.w,
          fit: BoxFit.fitHeight,
        ),
        SizedBox(width: 20.w),
      ],
    );
  }
}
